package com.dfbz.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_线程池的基本使用 {
    public static void main(String[] args) {

        // 创建一个大小为10的线程池
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        MyRunnable task = new MyRunnable();
        executorService.submit(task);
        executorService.submit(task);
        executorService.submit(task);


        // 关闭线程池
//        executorService.shutdown();
    }
}

class MyRunnable implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            System.out.println(Thread.currentThread().getName() + "===" + i);
        }
    }
}
